home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / ATL_Samples / count / counter.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  1.1 KB  |  55 lines

  1. // Counter.cpp : Implementation of CCounter
  2. #include "stdafx.h"
  3. #include "Count.h"
  4. #include "Counter.h"
  5.  
  6. #include "Object1.h"
  7.  
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CCounter
  10.  
  11.  
  12. HRESULT CCounter::OnDraw(ATL_DRAWINFO& di)
  13. {
  14.     HBRUSH hBrush, hOldBrush;
  15.     hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
  16.     hOldBrush = (HBRUSH)SelectObject(di.hdcDraw, hBrush);
  17.     RECT& rc = *(RECT*)di.prcBounds;
  18.     Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
  19.     SelectObject(di.hdcDraw, hOldBrush);
  20.  
  21.     return S_OK;
  22. }
  23.  
  24. STDMETHODIMP CCounter::StartCounting()
  25. {
  26.     if(m_pIObject)
  27.         m_pIObject->Start();
  28.  
  29.     return S_OK;
  30. }
  31.  
  32. STDMETHODIMP CCounter::SetMaxCounter(int nMax)
  33. {
  34.     if(m_pIObject)
  35.         m_pIObject->SetMax(nMax);
  36.  
  37.     return S_OK;
  38. }
  39.  
  40. STDMETHODIMP CCounter::GetInfoFromCounter(BSTR pInfo)
  41. {
  42.     HDC hDC = GetDC();
  43.     USES_CONVERSION;
  44.  
  45.     RECT rct;
  46.     GetClientRect(&rct);
  47.  
  48.     PatBlt(hDC, 1, 1, rct.right - 2, rct.bottom - 2, WHITENESS);
  49.     DrawText(hDC, OLE2T(pInfo), -1, &rct, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  50.  
  51.     ReleaseDC(hDC);
  52.  
  53.     return S_OK;
  54. }
  55.